﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="AlgorithmsSchema"
    targetNamespace="http://schemas.fanrui.net/CubeExercise/2009/09/AlgorithmFile"
    elementFormDefault="qualified"
    xmlns="http://schemas.fanrui.net/CubeExercise/2009/09/AlgorithmFile"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
    <xs:element name="AlgorithmFile" type="AlgorithmFile" />

    <xs:complexType name="Algorithm">
        <xs:attribute name="name" type="xs:string" use="required" />
        <xs:attribute name="id" type="xs:int" use="required" />
        <xs:attribute name="image" type="xs:string" />
        <xs:attribute name="script" type="xs:string" use="required" />
        <xs:attribute name="preScript" type="xs:string" />
        <xs:attribute name="postScript" type="xs:string" />
        <xs:attribute name="demo" type="xs:string" />
        <xs:attribute name="practiceTimes" type="xs:int" default="0" />
    </xs:complexType>

    <xs:complexType name="AlgorithmList">
        <xs:sequence maxOccurs="1">
            <xs:element name="Algorithm" minOccurs="0" maxOccurs="unbounded" nillable="false" type="Algorithm" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="AlgorithmReference">
        <xs:attribute name="id" type="xs:int" use="required" />
        <xs:attribute name="name" type="xs:string" use="optional" />
        <xs:attribute name="enabled" type="xs:boolean" default="true" />
        <xs:attribute name="demo" type="xs:string" />
    </xs:complexType>
    
    <xs:complexType name="Group">
        <xs:choice maxOccurs="unbounded">
            <xs:element name="AlgorithmReference" minOccurs="0" maxOccurs="1" type="AlgorithmReference" />
            <xs:element name="Group" minOccurs="0" maxOccurs="1" type="Group" />
        </xs:choice>
        <xs:attribute name="name" type="xs:string" />
        <xs:attribute name="enabled" type="xs:boolean" default="true" />
        <xs:attribute name="expanded" type="xs:boolean" default="true" />
    </xs:complexType>

    <xs:complexType name="AlgorithmFile">
        <xs:sequence minOccurs="1" maxOccurs="1">
            <xs:element name="Algorithms" minOccurs="1" maxOccurs="1" type="AlgorithmList" />
            <xs:element name="Group" minOccurs="1" maxOccurs="unbounded" type="Group" />
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" />
        <xs:attribute name="description" type="xs:string" use="optional" />
        <xs:attribute name="loadOnStart" type="xs:boolean" default="true" />
    </xs:complexType>
</xs:schema>
